Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codemirror/autocomplete

Package Overview
Dependencies
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/autocomplete

Autocompletion for the CodeMirror code editor

  • 6.18.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
increased by9.09%
Maintainers
2
Weekly downloads
 
Created

What is @codemirror/autocomplete?

The @codemirror/autocomplete package is a module for the CodeMirror code editor that provides autocompletion functionality. It can be used to suggest, complete, or hint at possible code snippets, variables, or other elements to users as they type, enhancing the coding experience by making it faster and reducing errors.

What are @codemirror/autocomplete's main functionalities?

Autocompletion

Enables autocompletion in the CodeMirror editor. As the user types, suggestions are displayed in a dropdown, allowing for quick insertion of code snippets.

import { autocompletion } from '@codemirror/autocomplete';

// To enable autocompletion in a CodeMirror editor
new EditorView({
  extensions: [autocompletion()],
  parent: document.body
});

Customizable Completion Source

Allows developers to provide a custom source for completions, enabling the suggestion of context-specific code snippets or keywords.

import { autocompletion, CompletionSource } from '@codemirror/autocomplete';

const myCompletionSource: CompletionSource = (context) => {
  // Custom logic to provide completions
  return [{ label: 'mySnippet', type: 'keyword' }];
};

// To use the custom completion source
new EditorView({
  extensions: [autocompletion({ override: [myCompletionSource] })],
  parent: document.body
});

Asynchronous Completion

Supports asynchronous computation of completions, allowing for the integration of dynamic data sources or external APIs for suggestions.

import { autocompletion, CompletionResult } from '@codemirror/autocomplete';

const asyncCompletionSource = async (context): Promise<CompletionResult> => {
  // Fetch or compute completions asynchronously
  return { from: context.pos, options: [{ label: 'asyncSnippet', type: 'function' }] };
};

// To use asynchronous completions
new EditorView({
  extensions: [autocompletion({ override: [asyncCompletionSource] })],
  parent: document.body
});

Other packages similar to @codemirror/autocomplete

Keywords

FAQs

Package last updated on 13 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc